import {
  getTaxConfig
} from '../utils.js';
import { caishui } from '../../lib/caishui.js';

const initBaseInfo = (companyInfo, saasTab) => {
  let taxConfig = getTaxConfig(companyInfo);

  if (!taxConfig.length) {
    caishui.notifications('暂不支持该省市的一键报税！');
    return;
  }
  if (/上海|江西/.test(taxConfig[0].name)) {
    if (!companyInfo.nationalTaxId) {
      caishui.notifications('请到crm中补充国税纳税人识别号！');
      return;
    }
  }

  // 基本信息
  Object.assign(window.baseInfo, { companyInfo, taxConfig, saasTab });

  let nationTaxSite = taxConfig.find(item => {
    return item.type === 'nation';
  });
  if (nationTaxSite && nationTaxSite.url) {
    chrome.tabs.create({
      url: nationTaxSite.url
    });
  }
};



export { initBaseInfo }